package cn.zhage.aimin.base.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

/*
 *
 * @author 渣哥
 */
public class BooleanDeserializer extends JsonDeserializer<Boolean> {
    @Override
    public Boolean deserialize(JsonParser parser, DeserializationContext context) throws IOException {
        String value = parser.getValueAsString();

        if (value == null || value.trim().isEmpty()) {
            return false;
        }
        String trimmedValue = value.trim();
        return "1".equals(trimmedValue);

    }
}
